#include "Palette.h"

#include <vector>
#include <string>
#include <QToolButton>
#include <QGridLayout>

using std::string;

Palette::Palette(QWidget *parent)
:	QWidget(parent),
	_iconPath("icons/"), _iconExt(".xpm"),
	_btnGroup(this),
	_layout(new QGridLayout)
{
	setLayout(_layout);
}

void Palette::add(const string& id, PaletteItemLr *listener)
{
	QToolButton *b = new QToolButton();
	b->setCheckable(true);
	b->setIcon(QIcon(_iconPath + id.c_str() + _iconExt));

	_btnGroup.addButton(b);
	// TODO properly implement GridLayout
	_layout->addWidget(b);

	if (listener)
		connect(b, SIGNAL(toggled(bool)), listener, SLOT(toggled(bool)));
}

